object dm: Tdm
  OldCreateOrder = False
  Height = 327
  Width = 709
  object UC: TUniConnection
    DataTypeMap = <>
    ProviderName = 'PostgreSQL'
    Database = 'zrl'
    SpecificOptions.Strings = (
      'SQLite.UseUnicode=True'
      'SQLite.ClientLibrary=sqlite3.dll'
      'SQLite.DefaultCollations=False'
      'PostgreSQL.UseUnicode=True')
    Username = 'postgres'
    Password = 'superuser'
    Server = '192.168.1.201'
    Connected = True
    Left = 88
    Top = 8
  end
  object q_org: TUniQuery
    SQLInsert.Strings = (
      'INSERT INTO org'
      '  (Name, kod, adress, direktor, glbuh)'
      'VALUES'
      '  (:Name, :kod, :adress, :direktor, :glbuh)')
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'select *'
      'from'
      'enterprise.org')
    Active = True
    Left = 88
    Top = 104
  end
  object ds_org: TUniDataSource
    DataSet = q_org
    OnStateChange = ds_orgStateChange
    Left = 88
    Top = 56
  end
  object SQLiteUniProvider1: TSQLiteUniProvider
    Left = 16
    Top = 8
  end
  object ds_ym_nod: TUniDataSource
    DataSet = q_ym_nod
    Left = 136
    Top = 56
  end
  object q_ym_nod: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'with a as ('
      
        'select substr(t.godmesn,1,4) as YEAR, CAST(null as varchar) as r' +
        'oot, substr(t.godmesn,1,4)||'#39' '#1088'.'#39' as name_desc'
      'FROM'
      'enterprise.payroll t'
      'group by substr(t.godmesn,1,4)'
      ''
      'union all'
      'SELECT s.godmesn, substr(s.godmesn,1,4),m.month_name'
      
        'from enterprise.payroll s left outer join enterprise.month m on ' +
        'cast(s.godmesn as integer)%100=m.month_number'
      'GROUP by s.godmesn,m.month_name'
      ''
      'union all'
      
        'SELECT t.godmesn||t.tab_no,t.godmesn,t.tab_no||'#39'_'#39'||w.surname||'#39 +
        ' '#39'||substr(w.name,1,1)||'#39'. '#39'||substr(w.midle_name,1,1)||'#39'.'#39
      
        'FROM enterprise.payroll t left outer join enterprise.workers w o' +
        'n t.tab_no=w.tab_no'
      'group by t.godmesn,t.tab_no,w.surname,w.name,w.midle_name'
      ')'
      ''
      
        'SELECT CAST(a.year as varchar(15)), cast(a.root as varchar(15)),' +
        ' cast(a.name_desc as varchar(20))'
      'from a')
    Active = True
    Left = 136
    Top = 104
  end
  object q_zrl: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      
        'select t.godmesr,t.godmesn,t.tab_no,t.knuz||'#39' '#39'||k.name_full as ' +
        'knuz,'
      
        'CASE when substr (k.knuz_kind,1,5)='#39#1053#1072#1088#1072#1093#39' THEN t.summa end as s' +
        'umma_n,'
      
        'CASE when substr (k.knuz_kind,1,5)='#39#1059#1090#1088#1080#1084#39' THEN t.summa end as s' +
        'umma_u'
      ',t.cf,t.df'
      'from enterprise.payroll t left outer JOIN enterprise.knuz k '
      #9'on t.knuz=k.knuz'
      'WHERE t.tab_no=:atab and t.godmesr=:agodmesr')
    Active = True
    Left = 184
    Top = 104
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'atab'
      end
      item
        DataType = ftUnknown
        Name = 'agodmesr'
      end>
  end
  object ds_zrl: TUniDataSource
    DataSet = q_zrl
    Left = 184
    Top = 56
  end
  object ds_work: TUniDataSource
    DataSet = q_work
    Left = 224
    Top = 56
  end
  object ds_work_data: TUniDataSource
    DataSet = q_work_data
    OnStateChange = ds_work_dataStateChange
    Left = 280
    Top = 56
  end
  object q_work: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      
        'select w.key,w.tab_no, CAST(w.surname||'#39' '#39'||substr(w.name,1,1)||' +
        #39'. '#39'|| substr(w.midle_name,1,1)||'#39'.'#39' as varchar(20))as fio,w.idk' +
        'od'
      'from enterprise.workers w')
    Active = True
    Left = 224
    Top = 104
  end
  object q_work_data: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      
        'select * --surname,name,midle_name,idkod,cast(w.passport as varc' +
        'har(8)) as passport,tab_no,adress,date_employment,date_dismissal'
      'from enterprise.workers w '
      'where w.key=:akey')
    Active = True
    Left = 280
    Top = 104
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'akey'
      end>
  end
  object ds_nu: TUniDataSource
    DataSet = q_nu
    Left = 336
    Top = 56
  end
  object q_nu: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'select *'
      'from'
      'enterprise.knuz')
    Active = True
    Left = 336
    Top = 104
  end
  object ds_timesh: TUniDataSource
    DataSet = q_timesh
    Left = 384
    Top = 56
  end
  object q_timesh: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      
        'select t.key,t.godmesr,t.godmesn,t.tab_no||'#39'_'#39'||w.surname||'#39' '#39'||' +
        'substr(w.name,1,1)||'#39'. '#39'||substr(w.midle_name,1,1)||'#39'.'#39' as tab_n' +
        'o,t.knuz||'#39'_'#39'||k.name as knuz,t.cp,t.dp,t.cf,t.df,t.summa'
      'from enterprise.timesheet t '
      'left outer join enterprise.workers w on t.tab_no=w.tab_no '
      'left outer join enterprise.knuz k on t.knuz=k.knuz '
      'WHERE t.tab_no=:atab and t.godmesr=(select a."YM" '
      'from enterprise.activemonth a'
      'where a.active=1)')
    Active = True
    Left = 384
    Top = 104
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'atab'
      end>
  end
  object ds_timesh_nod: TUniDataSource
    DataSet = q_timesh_nod
    Left = 440
    Top = 56
  end
  object q_timesh_nod: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'SELECT s.godmesr, CAST(null as varchar) as root,m.month_name'
      
        'from enterprise.timesheet s left outer join enterprise.month m o' +
        'n cast(s.godmesr as integer)%100=m.month_number'
      'where s.godmesr=(select a."YM" '
      'from enterprise.activemonth a'
      'where a.active=1) '
      'GROUP by s.godmesr,m.month_name'
      ''
      'union all'
      
        'SELECT t.godmesr||t.tab_no,t.godmesr,t.tab_no||'#39'_'#39'||w.surname||'#39 +
        ' '#39'||substr(w.name,1,1)||'#39'. '#39'||substr(w.midle_name,1,1)||'#39'.'#39
      
        'FROM enterprise.timesheet t left outer join enterprise.workers w' +
        ' on t.tab_no=w.tab_no'
      'where t.godmesr=(select a."YM" '
      'from enterprise.activemonth a'
      'where a.active=1)'
      'group by t.godmesr,t.tab_no,w.surname,w.name,w.midle_name')
    Active = True
    Left = 440
    Top = 104
  end
  object PostgreSQLUniProvider1: TPostgreSQLUniProvider
    Left = 32
    Top = 56
  end
  object proc_recalc_zrl: TUniStoredProc
    StoredProcName = 'enterprise.recalc_salary'
    SQLInsert.Strings = (
      'SELECT * FROM enterprise.recalc_zrl(:aym, :atab_no)')
    SQLDelete.Strings = (
      'SELECT * FROM enterprise.recalc_zrl(:aym, :atab_no)')
    SQLUpdate.Strings = (
      'SELECT * FROM enterprise.recalc_zrl(:aym, :atab_no)')
    SQLLock.Strings = (
      'SELECT * FROM enterprise.recalc_zrl(:aym, :atab_no)')
    SQLRefresh.Strings = (
      'SELECT * FROM enterprise.recalc_zrl(:aym, :atab_no)')
    DataTypeMap = <>
    Connection = UC
    Left = 32
    Top = 104
    ParamData = <
      item
        DataType = ftBoolean
        Name = 'result'
        ParamType = ptResult
      end
      item
        DataType = ftWideString
        Name = 'aym'
        ParamType = ptInput
      end
      item
        DataType = ftWideString
        Name = 'atab_no'
        ParamType = ptInput
      end>
    CommandStoredProcName = 'enterprise.recalc_salary'
  end
  object q_timesh_add: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'select *'
      'from enterprise.timesheet')
    Active = True
    Left = 384
    Top = 200
  end
  object ds_timesh_add: TUniDataSource
    DataSet = q_timesh_add
    OnStateChange = ds_timesh_addStateChange
    Left = 384
    Top = 152
  end
  object ds_aym: TUniDataSource
    Left = 648
    Top = 56
  end
  object q_aym: TUniQuery
    DataTypeMap = <>
    Connection = UC
    SQL.Strings = (
      'select  m.month_name||'#39' '#39'||substr(a."YM",1,4)||'#39#1088'.'#39' As aym'
      'from enterprise.activemonth a '
      
        #9'left outer join enterprise.month m on m.month_number =CAST(a."Y' +
        'M" as integer)%100'
      'where a.active=1')
    Active = True
    Left = 648
    Top = 104
  end
end
